const router = require('koa-router')()
const {
    noticeList,
    noticeAdd
} = require('../controller/notice')

router.prefix('/api/notice')

router.post('/add', async (ctx, next) => {
    const {
        userId,
        title,
        content,
        type,
        province,
        city,
        phone,
        weChat,
        activityTime
    } = ctx.request.body
    
    ctx.body = await noticeAdd({
        userId,
        title,
        content,
        type,
        province,
        city,
        phone,
        weChat,
        activityTime
    })
    
})

router.get('/list', async (ctx, next) => {
    const {
        province,
        city,
        type
    } = ctx.query
    const result =await noticeList({
        province,
        city,
        type
    })
    // const province = ctx.query.province || '全国'
    // const city = ctx.query.city || '全部'
    // const type = ctx.query.type || '全部'
    // const listData = await noticeList(province, city, type)
    ctx.body = result
})

module.exports = router
